import fetch from "node-fetch";
import getProxyAgent from "./proxy/getProxyAgent.js";
// import AtCoderTransformer from "./AtCoderTransformer.js";

// Package API(s) of one user of AtCoder
// Usage:
// const problems = await AtCoderProblem.getList()
export default class AtCoderProblem {
  static async getList() {
    let url = `https://kenkoooo.com/atcoder/resources/merged-problems.json`
    const response = await fetch(url, { agent: getProxyAgent() });
    const result = await response.json();
    if (result.length === 0) {
      throw new Error(`Atcoder get problem list failed`);
    }
    return result;
  }
}

// const res1 = await AtCoderProblem.getList()
// console.log(res1);
// const res = AtCoderTransformer.transformProblems(res1)
// console.log(res)